/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.com.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.PostLoad;
import javax.persistence.Table;

/**
 *
 * @author dloaiza
 */
@Entity
@Table(name = "TAB_CONTACTO")
@NamedQueries({
    @NamedQuery(name = "Contacto.findAll", query = "SELECT c FROM Contacto c")})
public class Contacto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "DSIDENTIFICACION", nullable = false, length = 30)
    private String dsidentificacion;
    @Column(name = "DSNOMBRE", length = 150)
    private String dsnombre;
    @Column(name = "DSAPELLIDO1", length = 50)
    private String dsapellido1;
    @Column(name = "DSAPELLIDO2", length = 50)
    private String dsapellido2;
    @Column(name = "DSTELEFONO", length = 10)
    private String dstelefono;
    @Column(name = "DSEXTENSION", length = 10)
    private String dsextension;
    @Column(name = "DSTELEFONO_CELULAR", length = 25)
    private String dstelefonoCelular;
    @Column(name = "DSCORREO", length = 250)
    private String dscorreo;
    @JoinColumn(name = "NMID_TIPO_DOCUMENTO", referencedColumnName = "ID_TIPO_DOCUMENTO")
    @ManyToOne(fetch = FetchType.LAZY)
    private TipoDocumento nmidTipoDocumento;
    @OneToMany(mappedBy = "dsidContacto", fetch = FetchType.LAZY)
    private List<Empresa> empresaList;
    @OneToMany(mappedBy = "dsidContacto", fetch = FetchType.LAZY)
    private List<Universidad> universidadList;

    public Contacto() {
    }

    public Contacto(String dsidentificacion) {
        this.dsidentificacion = dsidentificacion;
    }

    public String getDsidentificacion() {
        return dsidentificacion;
    }

    public void setDsidentificacion(String dsidentificacion) {
        this.dsidentificacion = dsidentificacion;
    }

    public String getDsnombre() {
        return dsnombre;
    }

    public void setDsnombre(String dsnombre) {
        this.dsnombre = dsnombre;
    }

    public String getDsapellido1() {
        return dsapellido1;
    }

    public void setDsapellido1(String dsapellido1) {
        this.dsapellido1 = dsapellido1;
    }

    public String getDsapellido2() {
        return dsapellido2;
    }

    public void setDsapellido2(String dsapellido2) {
        this.dsapellido2 = dsapellido2;
    }

    public String getDstelefono() {
        return dstelefono;
    }

    public void setDstelefono(String dstelefono) {
        this.dstelefono = dstelefono;
    }

    public String getDsextension() {
        return dsextension;
    }

    public void setDsextension(String dsextension) {
        this.dsextension = dsextension;
    }

    public String getDstelefonoCelular() {
        return dstelefonoCelular;
    }

    public void setDstelefonoCelular(String dstelefonoCelular) {
        this.dstelefonoCelular = dstelefonoCelular;
    }

    public String getDscorreo() {
        return dscorreo;
    }

    public void setDscorreo(String dscorreo) {
        this.dscorreo = dscorreo;
    }

    public TipoDocumento getNmidTipoDocumento() {
        return nmidTipoDocumento;
    }

    public void setNmidTipoDocumento(TipoDocumento nmidTipoDocumento) {
        this.nmidTipoDocumento = nmidTipoDocumento;
    }

    public List<Empresa> getEmpresaList() {
        return empresaList;
    }

    public void setEmpresaList(List<Empresa> empresaList) {
        this.empresaList = empresaList;
    }

    public List<Universidad> getUniversidadList() {
        return universidadList;
    }

    public void setUniversidadList(List<Universidad> universidadList) {
        this.universidadList = universidadList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dsidentificacion != null ? dsidentificacion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contacto)) {
            return false;
        }
        Contacto other = (Contacto) object;
        if ((this.dsidentificacion == null && other.dsidentificacion != null) || (this.dsidentificacion != null && !this.dsidentificacion.equals(other.dsidentificacion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.com.alexstarkbd.jpa.entities.Contacto[ dsidentificacion=" + dsidentificacion + " ]";
    }
    
    
    @PostLoad
    public void fixIt(){
        this.empresaList = new ArrayList<Empresa>(this.empresaList);
        this.universidadList = new ArrayList<Universidad>(this.universidadList);
    }
}
